package com.framework.modules.base.dao;

import com.framework.modules.base.entity.TokenEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.framework.modules.base.entity.UserEntity;
import com.framework.modules.base.entity.UserInfoEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * 用户Token
 * 
 * @author MIT
 * @email litmiss@gmail.com
 * @date 2020-10-03 16:01:48
 */
public interface TokenDao extends BaseMapper<TokenEntity> {

    @Select({"select c.id  as guild_id,b.* from tb_token a left join tb_user b on a.user_id=b.user_id left join tb_guild c on c.owner_uid=a.user_id where a.token = #{token} and a.platform = #{platform} limit 0,1"})
    Map<String,Object> getUserinfo(@Param("token") String token,@Param("platform")String platform);

    /**
     * 根据user_id和platform查询token是否存在就更新，不存在就新增
     * @return
     */
    Integer insertOrUpdateByUserIdAndPlatform(TokenEntity tokenEntity);

}
